/*/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package function;

import engine.goods.Goods;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import mainpackage.Constant;
import mainpackage.GameBean;
import mainpackage.MainCanvas;
import mainpackage.MainLogic;
import mainpackage.ResManager;
import mainpackage.Tools;
import ui.UiInterFace;

/**
 *
 * @author lenovo
 */
public class Equipment {

    private Image[] imgArray = null;
    private String[] sArray = null;
    private boolean bUiKeyPressLock = false;
    private byte byState = 0; //记录在跟新页面状态的时候的小状态
    public byte byItemSelectIndex = 1;
    public Goods items;
    public long lMoney = 0L;
    public int iStartX;
    public int iStartY;
    public String sTips = null;
    public String sEquipStrengthenRate = null;
    //物品强化等级
    public byte byStrengthenLevel = 0;
    //物品强化需要的宝石
    public byte byStrengthenGemNum = 0;
    //当前物品强化等级
    public short shStrengthenAddition = 0;
    //下个强化加成
    public short shNextStrengthenAddition = 0;
    public boolean bprotected = false;
    public short[] shGemType;
    public String[] sOpArray = null;
    private boolean bShowMenu = false;
    public byte byUiState = 0;
    public byte byPopUpState = 1;
    public short shHeight;
    private byte byMenuIndex = 0;
    public short shTipsW;
    public short shTipsH;
    public String sItemTips;
    public int iStartPointY;
    public int iWidth;
    public int iHeight;

    /*****************************打孔镶嵌*************************************************************/
    /**
     * 移除选中的物品
     * @param items  物品类
     * @param shPos 索引位置
     * @return
     */
    private boolean itemRemoveOperation(Goods items, short shPos) {
        if (!items.checkColumnHasGoods(shPos)) {
            return true;
        }
        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
            items.deleteGoods(shPos);
//            this.setDescPage();
            return true;
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
            return true;
        }
        return false;
    }

    /*********************************装备的操作*******************************************************/
    public void selectEquipOperationItems(Goods packageGoods, short shPos) {
        if (this.byItemSelectIndex == 1) {
            if (packageGoods.getGoodsCatalog(shPos) != Constant.ITEM_TYPE_WEAPONS && packageGoods.getGoodsCatalog(shPos) != Constant.ITEM_TYPE_EQUIP) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的物品类型不正确");
                return;
            } else if (this.items.checkColumnHasGoods((short) 0) && this.items.getGoodsColumnKey((short) 0) == packageGoods.getGoodsColumnKey(shPos)) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该物品您已经选择过了");
                return;
            } else {
                GameBean.b_WAIT_NET_MSG_BACK = true;
                GameBean.L_CMD_GOODS_SLOTKEY = packageGoods.getGoodsColumnKey(shPos);
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_HOLE_INFO, Constant.SOCKET_MSG_TYPE_LOGIC);
            }
        } else if (this.byItemSelectIndex >= 2 && this.byItemSelectIndex <= 4) {
            this.selectInlayGem(packageGoods, shPos);
        }
    }
    public byte[] byHoleType = null;

    /**
     * 初始化装备操作界面资源
     */
    public void initEquipOperation() {
        this.byState = 0;
        this.bUiKeyPressLock = false;
        items = new Goods((short) 4, Constant.ITEM_COLUMN_TYPE_COMMON);
        this.byItemSelectIndex = 1;
        this.lMoney = 0;
        this.byStrengthenLevel = 0;
        this.sTips = null;
        this.byUiState = 0;
        this.bShowMenu = false;
        this.byMenuIndex = 0;
        this.shHeight = 0;
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[11];
             this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();            //蓝色光片
             this.imgArray[2] = ResManager.createImage(90000017);            //背景图片
             this.imgArray[3] = ResManager.createImage(90000044);//白色的确定文字图片
             this.imgArray[4] = ResManager.createImage(1180);//宝石
             this.imgArray[5] = ResManager.createImage(90000043);            //文字图片
             this.imgArray[6] = Tools.makeTransparent(28, 28, 80, 0x000000);//物品白色的遮罩
             this.imgArray[7] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角提示图片
             this.imgArray[8] = ResManager.createImage(90000084);//方向键
             this.imgArray[9] = ResManager.createImage(90000085);//确定
             this.imgArray[10] = ResManager.createImage(90000086);//蓝条
            //#else
//#            this.imgArray = new Image[8];
//#            this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
//#            this.imgArray[1] = Tools.makeBlueMask();            //蓝色光片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017, Constant.RES_PUBLIC_TEMP, Constant.RES_UI_PATH, false, -1);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            //背景图片
//#            this.imgArray[2] = ResManager.createImage(90000017, Constant.RES_PUBLIC_TEMP, Constant.RES_UI_PATH, false, -1);
            //#endif
//#            this.imgArray[3] = ResManager.createImage(90000044);//白色的确定文字图片
//#            this.imgArray[4] = ResManager.createImage(1180);//宝石
//#//            this.imgArray[5] = ResManager.createImage(90000043);            //文字图片
//#            this.imgArray[6] = Tools.makeTransparent(28, 28, 80, 0x000000);//物品白色的遮罩
//#            this.imgArray[7] = Tools.makeTransparent(ResManager.createImage(90000051), 255);//圆角提示图片
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
        this.sArray = new String[]{"打孔镶嵌拆卸", "装备打孔情况", "镶嵌宝石： ", "宝石效果： ", "已镶嵌", "未镶嵌", "未打孔", "提示", "打孔装备道具", "请选择要打孔镶嵌拆卸的道具", "确定", "取消"};
//        this.items.addGoods((short) 0, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 1, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 2, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 3, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
        this.byItemSelectIndex = 1;
        this.byHoleType = new byte[3];
        for (byte i = 0; i < 3; i++) {
            byHoleType[i] = 3;
        }//1,已经镶嵌，2，已经打孔，3，未打孔
//        byHoleType[0] = 1;
//        byHoleType[1] = 2;
//        byHoleType[2] = 3;
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 54;
        //#elif NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 45;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 45;
        //#endif
    }

    /**
     * 绘制装备的操作界面
     * @param g
     */
    public void drawEquipOperation(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[8], this.imgArray[9], this.imgArray[10], this.imgArray[5], this.sArray[0]);
        //#elif NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], this.sArray[10], this.sArray[11], this.sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], this.sArray[10], this.sArray[11], this.sArray[0]);
        //#endif
        this.iStartY = this.iStartPointY;
        //绘制已已经选择的物品名称
        if (this.items.checkColumnHasGoods((short) 0)) {
            this.items.drawGoodsName(g, (short) 0, Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.items.sAlias[0])) >> 1), this.iStartY);
        } else {
            Tools.drawShadowString(g, (byte) 1, this.sArray[9], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.sArray[9])) >> 1), this.iStartY, 0xFFFFFF, 0x000000);
        }
        this.iStartY += Constant.FONT_SMALL_HEIGHT + 5;
        Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartY, Constant.DRAW_WIDTH);
        //需要操作的物品
        this.iStartY += 15;
        this.items.drawGoods(g, Constant.UI_START_X + (Constant.DRAW_WIDTH - Goods.byItemH >> 1), this.iStartY, (short) 0);
        //绘制装备打孔情况文字
        this.iStartY += 20 + Goods.byItemH;
        Tools.drawShadowString(g, (byte) 1, this.sArray[1], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.sArray[1])) >> 1), this.iStartY, 0xFFFFFF, 0x000000);
        //装饰横条
        Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartY + Constant.FONT_SMALL_HEIGHT + 5, Constant.DRAW_WIDTH);
        this.iStartY += 40;
        //绘制孔
        this.iStartX = Constant.UI_START_X + (Constant.DRAW_WIDTH - 102 - Constant.FONT_SMALL.stringWidth(this.sArray[4]) * 3) / 4;
        for (byte i = 1; i < 4; i++) {
            this.items.drawGoods(g, iStartX, this.iStartY, i, false, false);
            switch (this.byHoleType[i - 1]) {
                case 1:
                    //已经镶嵌
                    Tools.drawShadowString(g, (byte) 1, this.sArray[4], iStartX + Goods.byItemH + 3, iStartY + ((Goods.byItemH - Constant.FONT_SMALL_HEIGHT) >> 1), 0xFFFFFF, 0x000000);
                    break;
                case 2:
                    //已经打孔
                    g.drawImage(this.imgArray[4], iStartX + Tools.ceil(Goods.byItemH - 30, 2), iStartY + Tools.ceil(Goods.byItemH - 30, 2), 0);
                    g.drawImage(this.imgArray[6], iStartX + Tools.ceil(Goods.byItemH - 30, 2), iStartY + Tools.ceil(Goods.byItemH - 30, 2), 0);
                    Tools.drawShadowString(g, (byte) 1, this.sArray[5], iStartX + Goods.byItemH + 3, iStartY + ((Goods.byItemH - Constant.FONT_SMALL_HEIGHT) >> 1), 0xFFFFFF, 0x000000);
                    break;
                case 3:
                    //未打孔
                    Tools.drawShadowString(g, (byte) 1, this.sArray[6], iStartX + Goods.byItemH + 3, iStartY + ((Goods.byItemH - Constant.FONT_SMALL_HEIGHT) >> 1), 0xFFFFFF, 0x000000);
                    break;
            }
            this.iStartX += Goods.byItemH + 3 + Constant.FONT_SMALL.stringWidth(this.sArray[4]) + (Constant.DRAW_WIDTH - 102 - Constant.FONT_SMALL.stringWidth(this.sArray[4]) * 3) / 4;
        }
        if (this.byItemSelectIndex >= 1 && this.byItemSelectIndex <= 4) {
            if (this.byItemSelectIndex == 1) {
                this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - Goods.byItemH) >> 1);
                iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20;
            } else {
                this.iStartX = Constant.UI_START_X + (Constant.DRAW_WIDTH - 102 - Constant.FONT_SMALL.stringWidth(this.sArray[4]) * 3) / 4 + (this.byItemSelectIndex - 2) * (Goods.byItemH + 3 + Constant.FONT_SMALL.stringWidth(this.sArray[4]) + (Constant.DRAW_WIDTH - 102 - Constant.FONT_SMALL.stringWidth(this.sArray[4]) * 3) / 4);
            }
            this.items.drawSelectStyle(g, iStartX, iStartY);
            if (this.bShowMenu) {
                this.items.drawGoodsOperationMenu(g, this.sOpArray, this.byMenuIndex, iStartX, iStartY);
            }
            if (!this.bShowMenu && this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
                Tools.drawItemsPop(g, this.sItemTips, iStartX, this.iStartY, this.shTipsW, this.shTipsH);
            }
        }
        if (this.byUiState == 1) {
            //#if NOKIA_S60V5
             Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + (Constant.DRAW_WIDTH - 318 >> 1), Constant.UI_START_Y + ((Constant.END_LINE - this.shHeight) >> 1), 318, this.shHeight, this.imgArray[7], 0x9c9c9c, this.imgArray[3], 0, 0, 22, 10, this.imgArray[3], 22, 0, 21, 10, this.sArray[7], this.sTips);
            //#else
//#            Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + (Constant.DRAW_WIDTH - 232 >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.shHeight) >> 1), 232, this.shHeight, this.imgArray[7], 0x989898, this.imgArray[3], 0, 0, 22, 10, this.imgArray[3], 22, 0, 21, 10, this.sArray[7], this.sTips);
            //#endif
        }
    }

    private void makeItemsTips(Goods items, short shPos) {
        if (!items.checkColumnHasGoods(shPos)) {
            return;
        }
        short w = 0;
        this.shTipsW = (short) (Constant.FONT_SMALL.stringWidth(items.getGoodsAlias(shPos)));
        this.sItemTips = "<" + Tools.getColorReplaceLetter(Goods.getGoodsNameColor(items.getGoodsColor(shPos))) + items.getGoodsAlias(shPos) + ">";
        this.sItemTips += "|等级：" + items.getGoodsLevel(shPos);
        w = (short) (Constant.FONT_SMALL.stringWidth("|等级：" + items.getGoodsLevel(shPos)));
        this.shTipsW = this.shTipsW < w ? w : this.shTipsW;
        this.shTipsH = (short) ((Constant.FONT_SMALL_HEIGHT << 1) + 10);
        if (this.shTipsW < 40) {
            this.shTipsW = 40;
        }
        this.shTipsW += 10;
    }

    /**
     * 绘制装备的逻辑更新
     */
    public void updateEquipOperation() {
        if (GameBean.b_WAIT_NET_MSG_BACK) {
            return;
        }
        switch (this.byUiState) {
            case 0:
                if (!this.bUiKeyPressLock) {
                    if (!bShowMenu) {
                        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                            this.byItemSelectIndex = (byte) (this.byItemSelectIndex == 1 ? 3 : 1);
                            this.makeItemsTips(this.items, (short) (this.byItemSelectIndex - 1));
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                            this.byItemSelectIndex = (byte) (this.byItemSelectIndex > 1 ? 1 : 3);
                            this.makeItemsTips(this.items, (short) (this.byItemSelectIndex - 1));
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                            this.byItemSelectIndex = (byte) (this.byItemSelectIndex == 1 ? 4 : this.byItemSelectIndex - 1);
                            this.makeItemsTips(this.items, (short) (this.byItemSelectIndex - 1));
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                            this.byItemSelectIndex = (byte) (this.byItemSelectIndex == 4 ? 1 : this.byItemSelectIndex + 1);
                            this.makeItemsTips(this.items, (short) (this.byItemSelectIndex - 1));
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                            switch (this.byItemSelectIndex) {
                                case 1:
                                    MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                                    break;
                                case 2:
                                case 3:
                                case 4:
                                    this.byMenuIndex = 0;
                                    if (this.items.checkColumnHasGoods((short) 0)) {
                                        switch (this.byHoleType[this.byItemSelectIndex - 2]) {
                                            case 1:
                                                this.bShowMenu = true;
                                                this.sOpArray = new String[]{"查看", "普通拆卸", "无损拆卸"};
                                                break;
                                            case 2:
                                                this.bShowMenu = true;
                                                this.sOpArray = new String[]{"镶嵌"};
                                                break;
                                            case 3:
                                                this.bShowMenu = true;
                                                this.sOpArray = new String[]{"打孔"};
                                                break;
                                        }
                                    }
                                    break;
                            }

                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                        }
                    } else {
                        if (this.byItemSelectIndex < 2) {
                            this.bShowMenu = false;
                            return;
                        } else {
                            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                this.bShowMenu = false;
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 0);
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 1);
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                                this.bShowMenu = false;
                                switch (this.byHoleType[this.byItemSelectIndex - 2]) {
                                    case 1:
                                        switch (this.byMenuIndex) {
                                            case 0:
                                                MainLogic.getInstance().uiInterFace.sysMessage.checkStoreItem(this.items.getGoodsAlias((short) (this.byItemSelectIndex - 1)), this.items.getGoodsColor((short) (this.byItemSelectIndex - 1)), this.items.icon[this.byItemSelectIndex - 1], this.items.getGoodsKey((short) (this.byItemSelectIndex - 1)));
                                                break;
                                            case 1:
                                                //发送拆卸消息
                                                this.sTips = "拆卸后宝石会放入背包，同时宝石降一级(一级宝石消失),有一定的失败几率，您确定要继续么?";
                                                this.changeUiState();
                                                break;
                                            case 2:
                                                //保护拆卸
                                                this.sTips = "拆卸后宝石会放入背包，宝石完好无损，需要消耗保护符一个，您确定继续么?";
                                                this.changeUiState();
                                                break;

                                        }
                                        break;
                                    case 2:
                                        MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                                        break;
                                    case 3:
                                        if (this.items.checkColumnHasGoods((short) 0)) {
                                            GameBean.b_WAIT_NET_MSG_BACK = true;
                                            GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey((short) 0);
                                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_HOLE_MONEY, Constant.SOCKET_MSG_TYPE_LOGIC);
                                        } else {
                                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有选择要打孔的物品!");
                                        }
                                        break;
                                }
                            }
                        }

                    }
                }
                break;
            case 1:
                if (this.byPopUpState >= 4) {
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                        //发送消息
                        this.byUiState = 0;
                        switch (this.byHoleType[this.byItemSelectIndex - 2]) {
                            case 1:
                                switch (this.byMenuIndex) {
                                    case 1:
                                        //发送拆卸消息
                                        GameBean.b_WAIT_NET_MSG_BACK = true;
                                        GameBean.BY_OP_TYPE = 1;
                                        GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey((short) 0);
                                        GameBean.STR_CDM_GOODS_KEY = this.items.getGoodsKey((short) (this.byItemSelectIndex - 1));
                                        Tools.printLog("GameBean.STR_CDM_GOODS_KEY=" + GameBean.STR_CDM_GOODS_KEY);
                                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_DISMANTLE, Constant.SOCKET_MSG_TYPE_LOGIC);
                                        break;
                                    case 2:
                                        //保护拆卸
                                        GameBean.b_WAIT_NET_MSG_BACK = true;
                                        GameBean.BY_OP_TYPE = 2;
                                        GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey((short) 0);
                                        GameBean.STR_CDM_GOODS_KEY = this.items.getGoodsKey((short) (this.byItemSelectIndex - 1));
                                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_DISMANTLE, Constant.SOCKET_MSG_TYPE_LOGIC);
                                        break;
                                }
                                break;
                            case 2:
                                GameBean.b_WAIT_NET_MSG_BACK = true;
                                GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey((short) 0);
                                MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_INLAY, Constant.SOCKET_MSG_TYPE_LOGIC);
                                break;
                            case 3:
                                GameBean.b_WAIT_NET_MSG_BACK = true;
                                GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey((short) 0);
                                MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_HOLE, Constant.SOCKET_MSG_TYPE_LOGIC);
                                break;
                        }

                    } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                        this.byUiState = 0;
                    }
                } else {
                    this.byPopUpState++;
                }
                break;
        }
        MainCanvas.clearInput();
    }

    /**
     * 清除装备操作界面资源资源
     */
    public void clearEquipOperation() {
        this.imgArray = null;
        this.sArray = null;
        this.sOpArray = null;
        this.items = null;
        this.byHoleType = null;
        this.byItemSelectIndex = 1;
        this.sItemTips = null;
    }

    /**
     * 获得装备的打孔情况
     * @param stateCode
     * @param byHoleNum
     * @param GemNum
     */
    public void getEquipHoleInfo(byte stateCode, byte byHoleNum, byte GemNum) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "选择物品失败");
                break;
            case 1:
                this.byHoleType = new byte[]{3, 3, 3};
                switch (byHoleNum) {
                    case 0:
                        this.byHoleType[0] = 3;
                        this.byHoleType[1] = 3;
                        this.byHoleType[2] = 3;
                        break;
                    case 1:
                        if (GemNum == 1) {
                            this.byHoleType[0] = 1;
                        } else {
                            this.byHoleType[0] = 2;
                        }
                        this.byHoleType[1] = 3;
                        this.byHoleType[2] = 3;
                        break;
                    case 2:
                        if (GemNum == 0) {
                            this.byHoleType[0] = 2;
                            this.byHoleType[1] = 2;
                            this.byHoleType[2] = 3;
                        } else if (GemNum == 1) {
                            this.byHoleType[0] = 1;
                            this.byHoleType[1] = 2;
                            this.byHoleType[2] = 3;
                        } else if (GemNum == 2) {
                            this.byHoleType[0] = 1;
                            this.byHoleType[1] = 1;
                            this.byHoleType[2] = 3;
                        }
                        break;
                    case 3:
                        if (GemNum == 0) {
                            this.byHoleType[0] = 2;
                            this.byHoleType[1] = 2;
                            this.byHoleType[2] = 2;
                        } else if (GemNum == 1) {
                            this.byHoleType[0] = 1;
                            this.byHoleType[1] = 2;
                            this.byHoleType[2] = 2;
                        } else if (GemNum == 2) {
                            this.byHoleType[0] = 1;
                            this.byHoleType[1] = 1;
                            this.byHoleType[2] = 2;
                        } else if (GemNum == 3) {
                            this.byHoleType[0] = 1;
                            this.byHoleType[1] = 1;
                            this.byHoleType[2] = 1;
                        }
                        break;
                }
                this.items.goodsClone((short) 0, MainLogic.getInstance().uiPackage.getCurrentPackage(), MainLogic.getInstance().uiPackage.shPos);
                this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                MainLogic.getInstance().uiPackage.closeBag();
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该物品不能打孔镶嵌拆卸");
                break;
        }
    }

    /**
     * 选择镶嵌宝石
     * @param packageGoods
     * @param shPos
     */
    public void selectInlayGem(Goods packageGoods, short shPos) {
//        System.out.print("shPosshPos=" + shPos);
        if (packageGoods.getGoodsCatalog(shPos) != Constant.ITEM_TYPE_GEM) {
            MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "您选择的不是镶嵌宝石!");
            return;
        }
        this.byUiState = 1;
        GameBean.l_CMD_GOODS_SLOTKEY_SECOND = packageGoods.getGoodsColumnKey(shPos);
        this.sTips = "您确定要镶嵌宝石么？";
        this.shHeight = 80;
        //#if NOKIA_S40V3 || NORMAL_240_400 || MOTO || K790
//#         this.byPopUpState = 4;
        //#else
        this.byPopUpState = 0;
        //#endif
        MainLogic.getInstance().uiPackage.closeBag();
    }

    /**
     * 获得打孔要的金钱和宝石
     * @param stateCode
     * @param lMoney
     * @param byGemType
     */
    public void setHoleMoney(byte stateCode, long lMoney, byte byGemType) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "网络连接错误!");
                break;
            case 1:
                this.sTips = "打孔需要花费" + Tools.moneyConvert(lMoney) + "，需要消耗";
                switch (byGemType) {
                    case 1:
                        this.sTips += "白色打孔石";
                        break;
                    case 2:
                        this.sTips += "绿色打孔石";
                        break;
                    case 3:
                        this.sTips += "蓝色打孔石";
                        break;
                    case 4:
                        this.sTips += "紫色打孔石";
                        break;
                    case 5:
                        this.sTips += "橙色打孔石";
                        break;
                }
                this.sTips += "一个，您确定要打孔么？";
                this.changeUiState();
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "您选择的物品不能打孔!");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "物品已经达到打孔的上限!");
                break;
        }
    }

    /**
     * 改变ui装备
     */
    public void changeUiState() {
        this.shHeight = (short) (Tools.getParagraphHeight(this.sTips, Constant.DRAW_WIDTH - 8, Constant.FONT_SMALL_HEIGHT + 1) + 30);
        if (this.shHeight < 90) {
            this.shHeight = 90;
        }
        //#if NOKIA_S40V3 || NORMAL_240_400 || MOTO || K790
//#         this.byPopUpState = 4;
        //#else
        this.byPopUpState = 1;
        //#endif
        this.byUiState = 1;
    }

    /**
     * 完成打孔
     * @param stateCode
     */
    public void completeHole(byte stateCode) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "物品打孔出错");
                break;
            case 1:
                this.byHoleType[this.byItemSelectIndex - 2] = 2;
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "物品打孔成功");
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "装备不能打孔");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "该物品已经打了3个孔");
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "缺少打孔道具");
                break;
            case 5:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "您的金钱不够!");
                break;

        }

    }

    /**
     * 完成宝石镶嵌
     * @param stateCode
     * @param sGemKey
     * @param sGemName
     * @param iIconID
     * @param sDesc
     */
    public void completeInlay(byte stateCode, String sGemKey, String sGemName, int iIconID, String sDesc, byte byColor, byte byLevel) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "物品镶嵌出错");
                break;
            case 1:
                this.byHoleType[this.byItemSelectIndex - 2] = 1;
                this.items.addGoods((short) (this.byItemSelectIndex - 1), true, -1L, (byte) -1, sGemName, (short) 1, iIconID, (byte) -1, byColor, (byte) -1, (byte) -1, (byte) -1, sDesc, byLevel, -1, (byte) 100, sGemKey);
                this.items.sGoodsDesc[this.byItemSelectIndex - 1] = sDesc;
                this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "物品镶嵌成功");
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "您选择的宝石类型不正确");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "物品没有孔可以镶嵌");
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "您没有足够的金钱");
                break;
        }
    }

    /**
     * 完成宝石拆卸
     * @param stateCode
     * @param sGemName
     */
    public void completeDismantle(byte stateCode, String sGemName) {
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "宝石拆卸出错");
                break;
            case 1:
                this.byHoleType[this.byItemSelectIndex - 2] = 2;
                this.items.deleteGoods((short) (this.byItemSelectIndex - 1));
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "拆卸成功,您获得了宝石" + sGemName + "一个");
                break;
            case 2:
                this.byHoleType[this.byItemSelectIndex - 2] = 2;
                this.items.deleteGoods((short) (this.byItemSelectIndex - 1));
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "拆卸成功,宝石消失");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage(this.sArray[7], "您没有无损耗拆卸需要的保护符");
                break;
        }
    }

    /*************************物品强化***************************************************************************/
    /**
     * 从背包中选择强化物品
     * @param stateCode
     * @param money
     */
    public void selectStrengthenItem(Goods packageGoods, short shPos) {
        switch (this.byItemSelectIndex) {
            case 1:
                //选择要合成的装备，然后发送查询合成需要的金钱
                if (!(packageGoods.getGoodsCatalog(shPos) == Constant.ITEM_TYPE_EQUIP || packageGoods.getGoodsCatalog(shPos) == Constant.ITEM_TYPE_WEAPONS)) {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "请选择一件您要强化的装备道具!");
                } else if (packageGoods.getGoodsColumnKey(shPos) == this.items.getGoodsColumnKey((short) 0)) {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该道具您已经选择过了请重新选择!");
                } else {
                    GameBean.b_WAIT_NET_MSG_BACK = true;
                    GameBean.L_CMD_GOODS_SLOTKEY = packageGoods.getGoodsColumnKey(shPos);
                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_STRENGTH_MONEY, Constant.SOCKET_MSG_TYPE_LOGIC);
                }
                break;
            case 2:
                if (packageGoods.getGoodsCatalog(shPos) != Constant.ITEM_TYPE_GEM) {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "请选择一个装备强化宝石!");
                } else if (packageGoods.getGoodsColumnKey(shPos) == this.items.getGoodsColumnKey((short) 1)) {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该宝石您已经选择过了请重新选择!");
                } else {
                    GameBean.b_WAIT_NET_MSG_BACK = true;
                    GameBean.L_CMD_GOODS_SLOTKEY = packageGoods.getGoodsColumnKey(shPos);
                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_STRENGTH_RATE, Constant.SOCKET_MSG_TYPE_LOGIC);
                }
                break;
            case 3:
            case 4:
            case 5:
            case 6:
                if (packageGoods.getGoodsCatalog(shPos) != Constant.ITEM_TYPE_GEM) {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的物品类型不正确!");
                } else {
                    boolean isSelect = false;
                    for (byte i = 2; i < 6; i++) {
                        if (this.items.getGoodsColumnKey(i) == packageGoods.getGoodsColumnKey(shPos)) {
                            isSelect = true;
                            break;
                        }
                    }
                    if (isSelect) {
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该道具您已经选择过了请重新选择!");
                    } else {
                        GameBean.b_WAIT_NET_MSG_BACK = true;
                        GameBean.L_CMD_GOODS_SLOTKEY = packageGoods.getGoodsColumnKey(shPos);
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_STRENGTH_RATE, Constant.SOCKET_MSG_TYPE_LOGIC);
                    }
                }
                break;
        }
    }

    public void setStrengthenMoney(byte stateCode, Goods packageGoods, short shPos, long lMoney, byte byStrengthenGemNum, byte byStrengthenLevel, short shStrengthenAddition, short shNextStrengthenAddition) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "选择强化物品失败!!");
                break;
            case 1:
                this.lMoney = lMoney;
                this.byStrengthenGemNum = byStrengthenGemNum;
                this.byStrengthenLevel = byStrengthenLevel;
                this.shStrengthenAddition = shStrengthenAddition;
                this.shNextStrengthenAddition = shNextStrengthenAddition;
                this.items.goodsClone((short) 0, packageGoods, shPos);
                this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                int iPos = this.items.sAlias[0].indexOf("+");
                if (iPos > -1) {
                    this.items.sAlias[0] = this.items.sAlias[0].substring(0, iPos);
                }
                //记录从包裹中选择的索引
                MainLogic.getInstance().uiPackage.closeBag();
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的物品不能强化!!");
                break;
        }

    }

    public void completetItemsStrengthen(byte stateCode, long lMoney, byte byStrengthenGemNum, byte byStrengthenLevel, short shStrengthenAddition, short shNextStrengthenAddition) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品强化出错");
                break;
            case 1:
            case 6:
                if (this.items.getGoodsStackNum((short) 1) > this.byStrengthenGemNum) {
                    this.items.shStackNum[1] = (short) (this.items.getGoodsStackNum((short) 1) - this.byStrengthenGemNum);
                } else {
                    this.items.deleteGoods((short) 1);
                }
                for (byte i = 2; i < 6; i++) {
                    if (this.items.checkColumnHasGoods(i) && this.items.getGoodsStackNum((short) i) > 1) {
                        this.items.shStackNum[i] = (short) (this.items.getGoodsStackNum((short) i) - 1);
                    } else {
                        if (this.shGemType[(i - 2) * 2] == 1 || this.shGemType[(i - 2) * 2] == 2) {
                            this.shGemType[(i - 2) * 2] = 0;
                            this.shGemType[(i - 2) * 2 + 1] = 0;
                        }
                        this.items.deleteGoods(i);
                    }
                }
                this.lMoney = lMoney;
                this.byStrengthenGemNum = byStrengthenGemNum;
                this.byStrengthenLevel = byStrengthenLevel;
                this.shStrengthenAddition = shStrengthenAddition;
                this.shNextStrengthenAddition = shNextStrengthenAddition;
                this.countRate();
                if (stateCode == 1) {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品强化成功!");
                } else {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品强化升级失败!");
                    //this.sTips = "物品强化升级失败!";
                }
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品不能强化!");
                //this.sTips = "金钱不够!";
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "装备强化宝石不对!");
//                this.sTips = "装备强化宝石不对!";
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "金钱不够!");
//                this.sTips = "物品不能强化!";
                break;
            case 5:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "装备强化几率宝石不正确!");
//                this.sTips = "装备强化几率宝石不正确!";
                break;
            case 7:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "装备强化宝石不够!");
//                this.sTips = "装备强化宝石不够!";
                break;
            case 8:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "只能放置一个保底符!");
//                this.sTips = "只能放置一个保底符";
        }
    }

    /**
     * 计算强化的现有宝石的强化几率
     */
    public void countRate() {
        short shTotalRate = 0;
        this.bprotected = false;
        for (byte i = 0; i < 8; i += 2) {
            if (this.shGemType[i] == 1) {
                shTotalRate += this.shGemType[i + 1];
            } else if (this.shGemType[i] == 2) {
                this.bprotected = true;
            }
        }
        shTotalRate = (short) (shTotalRate > 10000 ? 10000 : shTotalRate);
        if (shTotalRate > 0) {
            this.sEquipStrengthenRate = String.valueOf(shTotalRate / 100);
            if (shTotalRate - shTotalRate / 100 * 100 > 0) {
                this.sEquipStrengthenRate = this.sEquipStrengthenRate + "." + String.valueOf(shTotalRate - shTotalRate / 100 * 100) + "%";
            } else {
                this.sEquipStrengthenRate = this.sEquipStrengthenRate + "%";
            }
        } else {
            this.sEquipStrengthenRate = "0%";
        }
    }

    public void setStrengthRate(byte stateCode, short rate, Goods packageGoods, short shPos) {
        Tools.printLog("rate=" + rate);
        Tools.printLog("stateCode=" + stateCode);
        GameBean.b_WAIT_NET_MSG_BACK = false;
        if (this.byItemSelectIndex == 2) {
            if (stateCode == 4) {
                this.items.goodsClone((short) 1, packageGoods, shPos);
                //记录从包裹中选择的索引
                MainLogic.getInstance().uiPackage.closeBag();
            } else {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的不是强化宝石!!");
            }
        } else {
            switch (stateCode) {
                case 0:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品选择失败!");
                    break;
                case 1:
                    this.items.goodsClone((short) (this.byItemSelectIndex - 1), packageGoods, shPos);
                    this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                    this.shGemType[(this.byItemSelectIndex - 3) * 2] = 1;
                    this.shGemType[(this.byItemSelectIndex - 3) * 2 + 1] = rate;
                    this.countRate();
                    //记录从包裹中选择的索引
                    MainLogic.getInstance().uiPackage.closeBag();
                    break;
                case 2:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的不是正确的宝石类型");
                    break;
                case 3:
                    if (this.bprotected) {
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您已经选择过保底符了!");
                    } else {
                        this.items.goodsClone((short) (this.byItemSelectIndex - 1), packageGoods, shPos);
                        this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                        this.shGemType[(this.byItemSelectIndex - 3) * 2] = 2;
                        this.shGemType[(this.byItemSelectIndex - 3) * 2 + 1] = 0;
                        this.countRate();
                        //记录从包裹中选择的索引
                        MainLogic.getInstance().uiPackage.closeBag();
                    }
                    break;
                default:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的物品类型不正确");
                    break;
            }
        }


    }

    /**
     * 初始化物品强化资源
     */
    public void initItemsStrengthen() {
        this.byState = 0;
        this.bUiKeyPressLock = false;

        this.byItemSelectIndex = 1;
        this.lMoney = 0;
        this.byStrengthenLevel = 0;
        this.sTips = null;
        this.byUiState = 0;
        this.bShowMenu = false;
        this.shHeight = 0;
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[7];
             this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();            //蓝色光片
             this.imgArray[2] = ResManager.createImage(90000017);            //背景图片
             this.imgArray[3] = ResManager.createImage(90000043);            //文字图片
             this.imgArray[4] = ResManager.createImage(90000084);            //方向键图片
             this.imgArray[5] = ResManager.createImage(90000085);            //确认图片
             this.imgArray[6] = ResManager.createImage(90000086);            //蓝条图片
            //#else
//#            this.imgArray = new Image[4];
//#            this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
//#            this.imgArray[1] = Tools.makeBlueMask();            //蓝色光片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            this.imgArray[2] = ResManager.createImage(90000017);            //背景图片
            //#endif
//#//            this.imgArray[3] = ResManager.createImage(90000043);            //文字图片
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
        //强化
        this.sOpArray = new String[]{"移除"};
        this.shGemType = new short[8];
        for (byte i = 0; i < 8; i++) {
            //0 没有，1：几率宝石,2:保底符
            this.shGemType[i] = 0;
        }
        this.sArray = new String[]{"装备强化", "装备与宝石", "宝石", "强化", "返回", "下一强化等级:", "提示：", "+", "开始强化", "几率宝石", "攻击力  +", "防御力  +", "强化石:", "龙币:", "成功加成:", "保底:", "保底", "不保底", "个"};
        items = new Goods((short) 6, Constant.ITEM_COLUMN_TYPE_COMMON);

//        this.items.addGoods((short) 0, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 1, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 2, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 3, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
        this.sEquipStrengthenRate = "0%";
        this.shStrengthenAddition = 0;
        this.byStrengthenLevel = 0;
        this.bprotected = false;
        //物品强化需要的宝石
        this.byStrengthenGemNum = 0;
        //当前物品强化等级
        this.shStrengthenAddition = 0;
        //下个强化加成
        this.shNextStrengthenAddition = 0;
        //#if NOKIA_E72
//#         Tools.initE72ScollBar();
        //#endif
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 54;
        //#elif NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 30;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 30;
        //#endif
    }

    /**
     * 绘制物品强化
     * @param g
     */
    public void drawItemsStrengthen(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[4], this.imgArray[5], this.imgArray[6], this.imgArray[3], 52, 2, 43, 22, this.imgArray[3], 247, 133, 45, 21, this.sArray[0]);
        //#elif NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], this.sArray[3], this.sArray[4], this.sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], this.sArray[3], this.sArray[4], this.sArray[0]);
        //#endif
        //装备与宝石
        this.iStartY = this.iStartPointY;
        Tools.drawShadowString(g, (byte) 1, this.sArray[1], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.sArray[1])) >> 1), this.iStartY + UiInterFace.iScreenOffsetH, 0xFFFFFF, 0x000000);
        this.iStartY += Constant.FONT_SMALL_HEIGHT + 5;
        Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartY + UiInterFace.iScreenOffsetH, Constant.DRAW_WIDTH);
        //要强化的物品的物品
        this.iStartY += 15;
        int iGap = (Constant.DRAW_WIDTH - Goods.byItemH * 2) / 3;
        items.drawGoods(g, Constant.UI_START_X + iGap, this.iStartY + UiInterFace.iScreenOffsetH, (short) 0);
        //加号
        Tools.drawShadowString(g, (byte) 1, this.sArray[7], Constant.UI_START_X + (Constant.DRAW_WIDTH - Constant.FONT_CHAR_WIDTH >> 1), this.iStartY + (Goods.byItemH - Constant.FONT_SMALL_HEIGHT >> 1) + UiInterFace.iScreenOffsetH, 0xFFFFFF, 0x000000);
        //宝石
        items.drawGoods(g, Constant.UI_START_X + (iGap << 1) + Goods.byItemH, this.iStartY + UiInterFace.iScreenOffsetH, (short) 1);
        //绘制几率宝石
        this.iStartY += Goods.byItemH + 10;
        Tools.drawShadowString(g, (byte) 1, this.sArray[9], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.sArray[9])) >> 1), this.iStartY + UiInterFace.iScreenOffsetH, 0xFFFFFF, 0x000000);
        Tools.drawSelectMask(g, (byte) 2, this.imgArray[1], Constant.UI_START_X, this.iStartY - 5 + UiInterFace.iScreenOffsetH, Constant.DRAW_WIDTH);
        this.iStartY += Constant.FONT_SMALL_HEIGHT + 15;
        iGap = (Constant.DRAW_WIDTH - (Goods.byItemH << 2)) / 5;
        this.iStartX = Constant.UI_START_X + iGap;
        for (byte i = 2; i < 6; i++) {
            items.drawGoods(g, iStartX + (i - 2) * (iGap + Goods.byItemH), this.iStartY + UiInterFace.iScreenOffsetH, i);
        }
        this.iStartX = Constant.UI_START_X + iGap;
        this.iStartY += Goods.byItemH + 15;
        if (this.items.checkColumnHasGoods((short) 0)) {
            if (this.byStrengthenLevel != 0) {
                Tools.drawShadowString(g, (byte) 1, this.items.getGoodsAlias((short) 0) + this.sArray[7] + String.valueOf(this.byStrengthenLevel), this.iStartX, this.iStartY + UiInterFace.iScreenOffsetH, 0xe1f265, 0x000000);
            } else {
                Tools.drawShadowString(g, (byte) 1, this.items.getGoodsAlias((short) 0), this.iStartX, this.iStartY + UiInterFace.iScreenOffsetH, 0xe1f265, 0x000000);
            }
        }
        g.setColor(0xFFFFFF);
        if (this.items.checkColumnHasGoods((short) 0) && this.items.getGoodsCatalog((short) 0) == Constant.ITEM_TYPE_WEAPONS) {
            g.drawString(this.sArray[10] + String.valueOf(this.shStrengthenAddition), this.iStartX, this.iStartY + Constant.FONT_SMALL_HEIGHT + 1 + UiInterFace.iScreenOffsetH, 0);
            g.drawString(this.sArray[10] + String.valueOf(this.shNextStrengthenAddition), this.iStartX, this.iStartY + (Constant.FONT_SMALL_HEIGHT + 1) * 3 + UiInterFace.iScreenOffsetH, 0);
            g.drawString(this.sArray[5], this.iStartX, this.iStartY + (Constant.FONT_SMALL_HEIGHT + 1) * 2 + UiInterFace.iScreenOffsetH, 0);
        } else if (this.items.checkColumnHasGoods((short) 0) && this.items.getGoodsCatalog((short) 0) == Constant.ITEM_TYPE_EQUIP) {
            g.drawString(this.sArray[11] + String.valueOf(this.shStrengthenAddition), this.iStartX, this.iStartY + Constant.FONT_SMALL_HEIGHT + 1 + UiInterFace.iScreenOffsetH, 0);
            g.drawString(this.sArray[11] + String.valueOf(this.shNextStrengthenAddition), this.iStartX, this.iStartY + (Constant.FONT_SMALL_HEIGHT + 1) * 3 + UiInterFace.iScreenOffsetH, 0);
            g.drawString(this.sArray[5], this.iStartX, this.iStartY + (Constant.FONT_SMALL_HEIGHT + 1) * 2 + UiInterFace.iScreenOffsetH, 0);
        }

        this.iStartX = Constant.UI_START_X + (Constant.DRAW_WIDTH >> 1);
        g.drawString(this.sArray[12] + String.valueOf(this.byStrengthenGemNum) + this.sArray[18], this.iStartX, this.iStartY + UiInterFace.iScreenOffsetH, 0);
        g.drawString(this.sArray[13] + Tools.moneyConvert(this.lMoney), this.iStartX, this.iStartY + (Constant.FONT_SMALL_HEIGHT + 1) + UiInterFace.iScreenOffsetH, 0);
        g.drawString(this.sArray[14] + this.sEquipStrengthenRate, this.iStartX, this.iStartY + (Constant.FONT_SMALL_HEIGHT + 1) * 2 + UiInterFace.iScreenOffsetH, 0);
        g.drawString(this.sArray[15] + (this.bprotected ? this.sArray[16] : this.sArray[17]), this.iStartX, this.iStartY + (Constant.FONT_SMALL_HEIGHT + 1) * 3 + UiInterFace.iScreenOffsetH, 0);
        switch (this.byItemSelectIndex) {
            case 1:
            case 2:
                iGap = (Constant.DRAW_WIDTH - Goods.byItemH * 2) / 3;
                this.iStartX = Constant.UI_START_X + iGap + (Goods.byItemH + iGap) * (this.byItemSelectIndex - 1);
                this.iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20;
                break;
            case 3:
            case 4:
            case 5:
            case 6:
                iGap = (Constant.DRAW_WIDTH - Goods.byItemH * 4) / 5;
                this.iStartX = Constant.UI_START_X + iGap + (Goods.byItemH + iGap) * (this.byItemSelectIndex - 3);
                this.iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20 + Goods.byItemH + 10 + Constant.FONT_SMALL_HEIGHT + 15;
                break;
        }
        this.items.drawSelectStyle(g, iStartX, iStartY + UiInterFace.iScreenOffsetH);
        if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
            if (!this.bShowMenu) {
                Tools.drawItemsPop(g, this.sItemTips, iStartX, iStartY + UiInterFace.iScreenOffsetH, this.shTipsW, this.shTipsH);
            } else {
                this.items.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX, iStartY + UiInterFace.iScreenOffsetH);
            }
        }

        //#if NOKIA_E72
//#         Tools.drawE72ScrollBar(g);
        //#endif
    }

    /**
     * 物品强化的逻辑更新
     */
    public void updateItemsStrengthen() {
        if (GameBean.b_WAIT_NET_MSG_BACK) {
            MainCanvas.clearInput();
            return;
        }
        if (!this.bUiKeyPressLock) {
            if (!bShowMenu) {
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                    switch (this.byItemSelectIndex) {
                        case 1:
                        case 2:
                            this.byItemSelectIndex = 3;
                            //#if NOKIA_E72
//#                                 Tools.updateE72ScollBar(-80);
                            //#endif
                            break;
                        case 3:
                        case 4:
                        case 5:
                        case 6:
                            this.byItemSelectIndex = 1;
                            //#if NOKIA_E72
//#                                 Tools.updateE72ScollBar(0);
                            //#endif
                            break;
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                    switch (this.byItemSelectIndex) {
                        case 1:
                        case 2:
                            this.byItemSelectIndex = 3;
                            //#if NOKIA_E72
//#                                 Tools.updateE72ScollBar(-80);
                            //#endif
                            break;
                        case 3:
                        case 4:
                        case 5:
                        case 6:
                            //#if NOKIA_E72
//#                                 Tools.updateE72ScollBar(0);
                            //#endif
                            this.byItemSelectIndex = 1;
                            break;
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                    this.byItemSelectIndex = (byte) (this.byItemSelectIndex == 1 ? 6 : this.byItemSelectIndex - 1);
                    //#if NOKIA_E72
//#                         if (this.byItemSelectIndex == 1 || this.byItemSelectIndex == 2) {
//#                             Tools.updateE72ScollBar(0);
//#                         } else {
//#                             Tools.updateE72ScollBar(-80);
//#                         }
                    //#endif
                    this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                    this.byItemSelectIndex = (byte) (this.byItemSelectIndex == 6 ? 1 : this.byItemSelectIndex + 1);
                    //#if NOKIA_E72
//#                         if (this.byItemSelectIndex == 1 || this.byItemSelectIndex == 2) {
//#                             Tools.updateE72ScollBar(0);
//#                         } else {
//#                             Tools.updateE72ScollBar(-80);
//#                         }
                    //#endif

                    this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                    if (!this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
                        MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                    } else {
                        this.bShowMenu = true;
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                    if (this.items.checkColumnHasGoods((short) 0) && this.items.checkColumnHasGoods((short) 1)) {
                        GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey((short) 0);
                        GameBean.l_CMD_GOODS_SLOTKEY_SECOND = this.items.getGoodsColumnKey((short) 1);
                        GameBean.BY_GOODS_NUM = (byte) (this.items.getGoodsNum() - 2);
                        GameBean.L_CMD_GOODS_SLOCKEY_ARRAY = null;
                        if (GameBean.BY_GOODS_NUM > 0) {
                            GameBean.L_CMD_GOODS_SLOCKEY_ARRAY = new long[GameBean.BY_GOODS_NUM];
                            byte j = 0;
                            for (byte i = 2; i < 6; i++) {
                                if (this.items.checkColumnHasGoods(i)) {
                                    GameBean.L_CMD_GOODS_SLOCKEY_ARRAY[j] = this.items.getGoodsColumnKey(i);
                                    j++;
                                }
                            }
                        }
                        GameBean.b_WAIT_NET_MSG_BACK = true;
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_STRENGTH, Constant.SOCKET_MSG_TYPE_LOGIC);
                    } else {
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有选择要强化的装备或是强化宝石");
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                    MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                }
            } else {
                if (this.itemRemoveOperation(this.items, (byte) (this.byItemSelectIndex - 1))) {
                    switch (this.byItemSelectIndex) {
                        case 1:
                            //物品强化等级
                            this.byStrengthenLevel = 0;
                            //物品强化需要的宝石
                            this.byStrengthenGemNum = 0;
                            //当前物品强化等级
                            this.shStrengthenAddition = 0;
                            //下个强化加成
                            this.shNextStrengthenAddition = 0;
                            this.lMoney = 0L;
                            break;
                        case 2:
                            break;
                        case 3:
                        case 4:
                        case 5:
                        case 6:
                            this.shGemType[(this.byItemSelectIndex - 3) * 2] = 0;
                            this.shGemType[(this.byItemSelectIndex - 3) * 2 + 1] = 0;
                            this.countRate();
                            break;
                    }
                    this.bShowMenu = false;
                }
            }
        }

        MainCanvas.clearInput();
    }

    /***
     * 清除物品强化资源
     */
    public void clearItemsStrengthen() {
        this.imgArray = null;
        this.sArray = null;
        this.sOpArray = null;
        this.items = null;
        this.byHoleType = null;
        this.byItemSelectIndex = 1;
        this.sItemTips = null;
        //#if NOKIA_E72
//#         Tools.clearE72ScollBar();;
        //#endif

    }

    /****************************************物品合成***********************************************************/
    /**
     * 从背包中选中合成物品
     * @param packageGoods
     * @param shPos
     */
    public void selectComposeItem(Goods packageGoods, short shPos) {
        boolean bSelected = false;
        GameBean.BY_GOODS_NUM = 0;
        for (byte i = 0; i < 3; i++) {
            if (this.items.checkColumnHasGoods(i)) {
                GameBean.BY_GOODS_NUM++;
            }
            if (packageGoods.getGoodsColumnKey(shPos) == this.items.getGoodsColumnKey(i)) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该装备道具您已经选过了,请重新选择!");
                return;
            }
        }
        if (GameBean.BY_GOODS_NUM >= 2) {
            byte byIndex[] = new byte[GameBean.BY_GOODS_NUM];
            byte j = 0;
            for (byte i = 0; i < 3; i++) {
                if (this.items.checkColumnHasGoods(i)) {
                    byIndex[j] = i;
                    j++;
                }
            }
        }
        this.items.goodsClone((short) (this.byItemSelectIndex - 1), packageGoods, shPos);
        this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
        MainLogic.getInstance().uiPackage.closeBag();
    }

    /**
     * 查询合成物品的金钱
     * @param stateCode
     * @param money
     * @param byStrengthenLevel
     * @param byHoleNum
     */
    public void setComposeMoney(byte stateCode, long money, int iPower, byte byStrengthenLevel, byte byHoleNum) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品合成出错!!");
                break;
            case 1:
                this.byUiState = 1;
                this.sTips = "物品合成需要花费" + Tools.moneyConvert(money) + ",花费" + iPower + "修为";
                if (byStrengthenLevel > 0 || byHoleNum > 0) {
                    this.sTips += "，合成后的物品强化等级为" + byStrengthenLevel + "，打孔数量为" + byHoleNum;
                }
                this.sTips += "您确定要合成么?";
                this.shHeight = (short) (Tools.getParagraphHeight(sTips, 202, Constant.FONT_SMALL_HEIGHT + 1) + 30);
                this.shHeight = this.shHeight < 90 ? 90 : this.shHeight;
                this.byPopUpState = 1;
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "装备镶嵌了宝石不能合成!");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "合成的物品类型不一致!");
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "找不到所选物品的合成规则!");
                break;
            case 5:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有足够的背包空间!!");
                break;
        }
    }

    /**
     * 完成合成
     * @param sGoodsKeys
     * @param iIconID
     * @param sGoodsName
     * @param byLevel
     */
    public void completeCompose(byte stateCode, long lGoodsColumnKey, int iIconID, String sGoodsName, short shLevel, short shStackNum, byte byDurability, byte byColor, byte[] byGoodsLeaveNum) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        this.byState = 0;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "道具合成出错");
                break;
            case 1:
            case 7:
                if (lGoodsColumnKey != -1) {
                    byte j = 0;
                    this.items.addGoods((short) 3, true, lGoodsColumnKey, (short) -1, sGoodsName, shStackNum, iIconID, (byte) -1, byColor, (byte) -1, (byte) -1, (byte) -1, null, shLevel, -1, byDurability, null);
                } else {
                    this.items.deleteGoods((short) 3);
                }
                if (byGoodsLeaveNum != null) {
                    byte j = 0;
                    for (byte i = 0; i < 3; i++) {
                        if (this.items.checkColumnHasGoods(i)) {
                            if (byGoodsLeaveNum[j] == 0) {
                                this.items.deleteGoods(i);
                            } else {
                                this.items.shStackNum[i] = byGoodsLeaveNum[j];
                            }
                            j++;
                        }
                    }
                }
                this.byState = 1;
                if (stateCode == 1) {
                    this.byState = 1;
                    this.byItemSelectIndex = 4;
                    this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "道具合成成功,恭喜您合成了“<" + Tools.getColorReplaceLetter(Goods.getGoodsNameColor(byColor)) + sGoodsName + ">”");
                } else {
                    this.byState = -1;
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "道具合成失败！");
                }
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "装备镶嵌了宝石不能合成");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品数量不足");
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "这些物品不可以合成!");
                break;
            case 5:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的背包空间不够!");
                break;
            case 6:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "金钱不足!!");
                break;
            case 8:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "修为不足，不能合成物品!!");
                break;
        }

    }

    /**
     * 初始化物品合成资源
     */
    public void initItemsCompose() {
        this.byState = 0;
        this.bUiKeyPressLock = false;
        this.byItemSelectIndex = 1;
        this.lMoney = 0;
        this.sTips = null;
        this.byUiState = 0;
        this.bShowMenu = false;
        this.shHeight = 0;
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[9];
             this.imgArray[0] = ResManager.createImage(90000041);//箭头图片
             this.imgArray[1] = Tools.makeBlueMask();//蓝色光片
             this.imgArray[2] = ResManager.createImage(90000017);            //背景图片
             this.imgArray[3] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
             this.imgArray[4] = ResManager.createImage(90000043);//文字图片
             this.imgArray[5] = ResManager.createImage(90000044);//白色确定文字图片
             this.imgArray[6] = ResManager.createImage(90000084);//方向按键
             this.imgArray[7] = ResManager.createImage(90000085);//确认按键
             this.imgArray[8] = ResManager.createImage(90000086);//蓝条
            //#else
//#            this.imgArray = new Image[6];
//#            this.imgArray[0] = ResManager.createImage(90000041);//箭头图片
//#            this.imgArray[1] = Tools.makeBlueMask();//蓝色光片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            this.imgArray[2] = ResManager.createImage(90000017);            //背景图片
            //#endif
//#            this.imgArray[3] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
//#            this.imgArray[4] = ResManager.createImage(90000043);//文字图片
//#            this.imgArray[5] = ResManager.createImage(90000044);//白色确定文字图片
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 54;
        //#elif NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 40;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 45;
        //#endif
        //合成
        this.sOpArray = new String[]{"移除"};
        this.sArray = new String[]{"物品合成", "选择合成物品", "成品", "开始合成", "返回", "合成费用:", "提示：", "合成后物品强化等级:", "合成后物品孔数：", " +"};
        items = new Goods((short) 4, Constant.ITEM_COLUMN_TYPE_COMMON);
//        this.items.addGoods((short) 0, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 1, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 2, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 3, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
    }

    /**
     * 绘制装备合成
     */
    public void drawItemsCompose(Graphics g) {
        //绘制合成材料物品方框
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[6], this.imgArray[7], this.imgArray[8], this.imgArray[4], 52, 2, 43, 22, this.imgArray[4], 247, 106, 45, 21, this.sArray[0]);
        //#elif NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], this.sArray[3], this.sArray[4], this.sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], this.sArray[3], this.sArray[4], this.sArray[0]);
        //#endif
        this.iStartY = this.iStartPointY;
        Tools.drawShadowString(g, (byte) 1, this.sArray[1], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.sArray[1])) >> 1), this.iStartY, 0xFFFFFF, 0x000000);
        this.iStartY += Constant.FONT_SMALL_HEIGHT + 5;
        Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartY, Constant.DRAW_WIDTH);
        //装饰横条
        Tools.drawSelectMask(g, (byte) 2, this.imgArray[1], Constant.UI_START_X, this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20 + Goods.byItemH + 15, Constant.DRAW_WIDTH);
        Tools.drawShadowString(g, (byte) 1, this.sArray[2], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.sArray[2])) >> 1), this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20 + Goods.byItemH + 20, 0xFFFFFF, 0x000000);
        for (byte i = 0; i < 4; i++) {
            switch (i) {
                case 0:
                case 1:
                case 2:
                    iStartX = Constant.UI_START_X + (Constant.DRAW_WIDTH - Goods.byItemH >> 1) + (i - 1) * 80;
                    iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20;
                    break;
                case 3:
                    iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - Goods.byItemH) >> 1);
                    iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20 + Goods.byItemH + 20 + Constant.FONT_SMALL_HEIGHT + 10;
                    break;
            }
            items.drawGoods(g, iStartX, iStartY, i, false, true);
        }
        switch (this.byItemSelectIndex) {
            case 1:
            case 2:
            case 3:
                iStartX = Constant.UI_START_X + (Constant.DRAW_WIDTH - Goods.byItemH >> 1) + (byItemSelectIndex - 2) * 80;
                iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20;
                break;
            case 4:
                iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - Goods.byItemH) >> 1);
                iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20 + Goods.byItemH + 20 + Constant.FONT_SMALL_HEIGHT + 10;
                break;
        }
        this.items.drawSelectStyle(g, iStartX, iStartY);
        if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
            if (!this.bShowMenu) {
                Tools.drawItemsPop(g, this.sItemTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
            } else {
                Goods.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX, iStartY);
            }
        }
        if (this.byUiState == 1) {
            //#if NOKIA_S60V5
             Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1), Constant.UI_START_Y + ((Constant.END_LINE - this.shHeight) >> 1), 318, this.shHeight, this.imgArray[3], 0x9c9c9c, this.imgArray[5], 0, 0, 22, 10, this.imgArray[5], 22, 0, 21, 10, this.sArray[6], this.sTips);
            //#else
//#            Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.shHeight) >> 1), 232, this.shHeight, this.imgArray[3], 0x989898, this.imgArray[5], 0, 0, 22, 10, this.imgArray[5], 22, 0, 21, 10, this.sArray[6], this.sTips);
            //#endif
        }
    }

    /**
     * 物品合成的逻辑更新
     */
    public void updateItemsCompose() {
        if (GameBean.b_WAIT_NET_MSG_BACK) {
            MainCanvas.clearInput();
            return;
        }
        switch (this.byUiState) {
            case 0:
                if (!this.bUiKeyPressLock) {
                    if (!bShowMenu) {
                        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                            this.byItemSelectIndex = (byte) (this.byItemSelectIndex == 4 ? 2 : 4);
                            this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                            this.byItemSelectIndex = (byte) (this.byItemSelectIndex == 1 ? 4 : this.byItemSelectIndex - 1);
                            this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                            this.byItemSelectIndex = (byte) (this.byItemSelectIndex == 4 ? 1 : this.byItemSelectIndex + 1);
                            this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                            switch (this.byItemSelectIndex) {
                                case 1:
                                case 2:
                                case 3:
                                    if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
                                        this.sOpArray = new String[]{"移除"};
                                        this.bShowMenu = true;
                                    } else {
                                        MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                                    }
                                    break;
                                case 4:
                                    if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
                                        this.sOpArray = new String[]{"查看"};
                                        this.bShowMenu = true;
                                    }
                                    break;
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                            //发送消息,先查询金钱
                            GameBean.BY_GOODS_NUM = 0;
                            for (byte i = 0; i < 3; i++) {
                                if (this.items.checkColumnHasGoods(i)) {
                                    GameBean.BY_GOODS_NUM++;
                                }
                            }
                            if (GameBean.BY_GOODS_NUM >= 1) {
                                GameBean.L_CMD_GOODS_SLOCKEY_ARRAY = new long[GameBean.BY_GOODS_NUM];
                                byte j = 0;
                                for (byte i = 0; i < 3; i++) {
                                    if (this.items.checkColumnHasGoods(i)) {
                                        GameBean.L_CMD_GOODS_SLOCKEY_ARRAY[j] = this.items.getGoodsColumnKey(i);
                                        j++;
                                    }
                                }
                                GameBean.b_WAIT_NET_MSG_BACK = true;
                                MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_COMPOSE_MONEY, Constant.SOCKET_MSG_TYPE_LOGIC);
                            } else {
                                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有选择要合成的物品!");
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                        }
                    } else {
                        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                            if (this.byItemSelectIndex > 0 && this.byItemSelectIndex < 4) {
                                this.bShowMenu = false;
                                this.items.deleteGoods((short) (this.byItemSelectIndex - 1));
                            } else if (this.byItemSelectIndex == 4) {//String sItemName, byte byItemColor, Image itemIcon, long lPlayerID, long lItemSlotkeyID
                                this.bShowMenu = false;
                                MainLogic.getInstance().uiInterFace.sysMessage.checkItem(this.items.getGoodsAlias((short) (this.byItemSelectIndex - 1)), this.items.getGoodsColor((short) (this.byItemSelectIndex - 1)), this.items.getGoodsIcon((short) (this.byItemSelectIndex - 1)), MainLogic.getInstance().gamePlayer.lPlayerID, this.items.getGoodsColumnKey((short) (this.byItemSelectIndex - 1)));
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                            this.bShowMenu = false;
                        }
                    }
                }

                break;
            case 1:
                if (this.byPopUpState >= 4) {
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                        GameBean.BY_GOODS_NUM = 0;
                        for (byte i = 0; i < 3; i++) {
                            if (this.items.checkColumnHasGoods(i)) {
                                GameBean.BY_GOODS_NUM++;
                            }
                        }
                        if (GameBean.BY_GOODS_NUM >= 1) {
                            GameBean.L_CMD_GOODS_SLOCKEY_ARRAY = new long[GameBean.BY_GOODS_NUM];
                            byte j = 0;
                            for (byte i = 0; i < 3; i++) {
                                if (this.items.checkColumnHasGoods(i)) {
                                    GameBean.L_CMD_GOODS_SLOCKEY_ARRAY[j] = this.items.getGoodsColumnKey(i);
                                    j++;
                                }
                            }
                            GameBean.b_WAIT_NET_MSG_BACK = true;
                            this.byUiState = 0;
                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_COMPOSE, Constant.SOCKET_MSG_TYPE_LOGIC);
                        } else {
                            this.byUiState = 0;
                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有选择要合成的物品!");
                        }
                    } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                        this.byUiState = 0;
                    }
                } else {
                    this.byPopUpState++;
                }

                break;
        }
        MainCanvas.clearInput();
    }

    /**
     * 清除物品合成资源
     */
    public void clearItemsCompose() {
        this.imgArray = null;
        this.sArray = null;
        this.sOpArray = null;
        this.items = null;
        this.byHoleType = null;
        this.byItemSelectIndex = 1;
        this.sItemTips = null;
    }

    /****************************物品分解************************************************************************************/
    /**
     * 从背包中选择要分解的物品
     * @param packageGoods
     * @param shPos
     */
    public void selectDeComposeItem(Goods packageGoods, short shPos) {
        if (packageGoods.getGoodsColumnKey(shPos) == this.items.getGoodsColumnKey((short) 0)) {
            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该装备道具您已经选过了,请重新选择!");
        } else {
            this.items.goodsClone((short) 0, packageGoods, shPos);
            this.makeItemsTips(items, (short) 0);
            this.items.bIsGetGoodsDesc[(short) 0] = false;
            this.items.deleteGoods((short) 1);
            this.items.deleteGoods((short) 2);
            this.items.deleteGoods((short) 3);
            MainLogic.getInstance().uiPackage.closeBag();
        }
    }

    public void completeItemsDeCompose(byte stateCode) {
        this.lMoney = 0L;
        this.sTips = null;
        Tools.printLog("stateCode=" + stateCode);
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品分解失败");
                break;
            case 1:
                this.items.deleteGoods((short) 0);
                this.byItemSelectIndex = 2;
                this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品分解成功");
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "背包里空间不够");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该物品不能分解");
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "金钱不够");
                break;
            case 5:
                this.items.deleteGoods((short) 0);
                this.byItemSelectIndex = 2;
                this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品完美分解");
                break;
        }
    }

    /**
     * 物品分解界面资源初始化
     */
    public void initItemsDecompose() {
        this.byState = 0;
        this.bUiKeyPressLock = false;
        this.byItemSelectIndex = 1;
        this.lMoney = 0;
        this.sTips = null;
        this.byUiState = 0;
        this.shHeight = 90;
        this.bShowMenu = false;
        this.sOpArray = new String[]{"查看"};
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[9];
             this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
             this.imgArray[1] = Tools.makeBlueMask();            //蓝色光片
             this.imgArray[2] = ResManager.createImage(90000017);            //背景图片
             this.imgArray[3] = Tools.makeTransparent(ResManager.createImage(90000051), 255);            //弹出提示图片
             this.imgArray[4] = ResManager.createImage(90000043);//文字图片
             this.imgArray[5] = ResManager.createImage(90000044);//白色确定
             this.imgArray[6] = ResManager.createImage(90000084);//方向按键
             this.imgArray[7] = ResManager.createImage(90000085);//确认按键
             this.imgArray[8] = ResManager.createImage(90000086);//蓝条
            //#else
//#            this.imgArray = new Image[6];
//#            this.imgArray[0] = ResManager.createImage(90000041);            //箭头图片
//#            this.imgArray[1] = Tools.makeBlueMask();            //蓝色光片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400 
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            this.imgArray[2] = ResManager.createImage(90000017);            //背景图片
            //#endif
//#            this.imgArray[3] = Tools.makeTransparent(ResManager.createImage(90000051), 255);            //弹出提示图片
//#//            this.imgArray[4] = ResManager.createImage(90000043);//文字图片
//#            this.imgArray[5] = ResManager.createImage(90000044);//白色确定
            //#endif
            //测试
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 54;
        //#elif NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 40;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 45;
        //#endif
        //分解
        this.sArray = new String[]{"装备分解", "选择分解物品", "分解后材料", "开始分解", "返回"};
        items = new Goods((short) 4, Constant.ITEM_COLUMN_TYPE_COMMON);
//        this.items.addGoods((short) 0, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 1, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 2, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 3, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
    }

    /**
     * 绘制物品分解
     * @param g
     */
    public void drawItemsDecompose(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[6], this.imgArray[7], this.imgArray[8], this.imgArray[4], 52, 2, 43, 22, this.imgArray[4], 198, 133, 45, 21, this.sArray[0]);
        //#elif NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], this.sArray[3], this.sArray[4], this.sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], this.sArray[3], this.sArray[4], this.sArray[0]);
        //#endif
        this.iStartY = this.iStartPointY;
        if (this.items.checkColumnHasGoods((short) 0)) {
            this.items.drawGoodsName(g, (short) 0, Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.items.getGoodsAlias((short) 0))) >> 1), iStartY);
        } else {
            Tools.drawShadowString(g, (byte) 1, this.sArray[1], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.sArray[1])) >> 1), this.iStartY, 0xFFFFFF, 0x000000);
        }
        Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartY + Constant.FONT_SMALL_HEIGHT + 5, Constant.DRAW_WIDTH);
//        Tools.drawSelectMask(g, (byte) 2, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_Y + 157, Constant.DRAW_WIDTH);
        this.iStartX = Constant.UI_START_X + (Constant.DRAW_WIDTH - Goods.byItemH >> 1);
        this.iStartY += Constant.FONT_SMALL_HEIGHT + 20;
        //被分解的物品
        items.drawGoods(g, this.iStartX, this.iStartY, (short) 0, false, true);
        this.iStartY += Goods.byItemH + 20;
        //分解材料文字
        Tools.drawShadowString(g, (byte) 1, this.sArray[2], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.sArray[2])) >> 1), this.iStartY, 0xFFFFFF, 0x000000);
        Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iStartY + Constant.FONT_SMALL_HEIGHT + 5, Constant.DRAW_WIDTH);

        this.iStartY += Constant.FONT_SMALL_HEIGHT + 10;
        //分解后的材料
        for (byte i = 1; i <= 3; i++) {
            items.drawGoods(g, iStartX + (i - 2) * 80, this.iStartY, i, false, true);
        }
        switch (this.byItemSelectIndex) {
            case 1:
                this.iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20;
                break;
            case 2:
            case 3:
            case 4:
                this.iStartX = Constant.UI_START_X + (Constant.DRAW_WIDTH - Goods.byItemH >> 1) + (this.byItemSelectIndex - 3) * 80;
                this.iStartY = this.iStartPointY + 20 + Constant.FONT_SMALL_HEIGHT + Goods.byItemH + 20 + Constant.FONT_SMALL_HEIGHT + 10;
                break;

        }
        this.items.drawSelectStyle(g, iStartX, iStartY);
        if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
            if (!this.bShowMenu) {
                Tools.drawItemsPop(g, this.sItemTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
            } else {
                this.items.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX, iStartY);
            }
        }
        if (this.byUiState == 1) {
            //#if NOKIA_S60V5
             Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1), Constant.UI_START_Y + ((Constant.END_LINE - this.shHeight) >> 1), 318, this.shHeight, this.imgArray[3], 0x989898, this.imgArray[5], 0, 0, 22, 10, this.imgArray[5], 22, 0, 21, 10, this.sArray[0], this.sTips);
            //#else
//#            Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - this.shHeight) >> 1), 232, this.shHeight, this.imgArray[3], 0x989898, this.imgArray[5], 0, 0, 22, 10, this.imgArray[5], 22, 0, 21, 10, this.sArray[0], this.sTips);
            //#endif
        }
    }

    /**
     * 物品分解的逻辑更新
     */
    public void updateItemsDecompose() {
        if (GameBean.b_WAIT_NET_MSG_BACK) {
            MainCanvas.clearInput();
            return;
        }
        switch (this.byUiState) {
            case 0:
                if (!this.bUiKeyPressLock) {
                    if (!this.bShowMenu) {
                        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                            switch (this.byItemSelectIndex) {
                                case 1:
                                    this.byItemSelectIndex = 3;
                                    break;
                                default:
                                    this.byItemSelectIndex = 1;
                                    break;
                            }
                            this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                            switch (this.byItemSelectIndex) {
                                case 1:
                                    this.byItemSelectIndex = 3;
                                    break;
                                default:
                                    this.byItemSelectIndex = 1;
                                    break;
                            }
                            this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                            this.byItemSelectIndex = (byte) (this.byItemSelectIndex == 1 ? 4 : this.byItemSelectIndex - 1);
                            this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                            this.byItemSelectIndex = this.byItemSelectIndex == 4 ? 1 : (byte) (this.byItemSelectIndex + 1);
                            this.makeItemsTips(items, (short) (this.byItemSelectIndex - 1));
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                            switch (this.byItemSelectIndex) {
                                case 1:
                                    MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                                    break;
                                case 2:
                                case 3:
                                case 4:
                                    if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
                                        this.bShowMenu = true;
                                    }
                                    break;
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                            if (this.items.checkColumnHasGoods((short) 0)) {
                                GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey((short) 0);
                                this.byUiState = 1;
                                this.sTips = "物品被分解后会消失，您确定要分解该物品么?";
                                this.shHeight = (short) Tools.getParagraphHeight(sTips, 202, Constant.FONT_SMALL_HEIGHT + 1);
                                if (this.shHeight < 60) {
                                    this.shHeight = 90;
                                }
                            } else {
                                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有选择要分解的装备");
                            }
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                        }
                    } else {
                        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                            this.bShowMenu = false;
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                            this.bShowMenu = false;
                            MainLogic.getInstance().uiInterFace.sysMessage.checkItem(this.items.getGoodsAlias((short) (this.byItemSelectIndex - 1)), this.items.getGoodsColor((short) (this.byItemSelectIndex - 1)), this.items.getGoodsIcon((short) (this.byItemSelectIndex - 1)), MainLogic.getInstance().gamePlayer.lPlayerID, this.items.getGoodsColumnKey((short) (this.byItemSelectIndex - 1)));
                        }
                    }
                }
                break;
            case 1:
                if (this.byPopUpState >= 4) {
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                        //发送消息
                        this.byUiState = 0;
                        //发送分解信息
                        GameBean.b_WAIT_NET_MSG_BACK = true;
                        GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey((short) 0);
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_DECOMPOSE, Constant.SOCKET_MSG_TYPE_LOGIC);
                        break;
                    } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                        this.byUiState = 0;
                    }
                } else {
                    this.byPopUpState++;
                }
                break;
        }
        MainCanvas.clearInput();
    }

    /**
     * 清除物品分解资源
     */
    public void clearItemsDecompose() {
        this.imgArray = null;
        this.sArray = null;
        this.sOpArray = null;
        this.items = null;
        this.byHoleType = null;
        this.byItemSelectIndex = 1;
    }

    public void setRollText(String text, int width) {
        this.shHeight = (short) Tools.getParagraphHeight(text, (short) width, Constant.FONT_SMALL_HEIGHT);
        Tools.rollIndex = 0;
        Tools.lastUpdateTime = System.currentTimeMillis();

    }
}
